<script setup lang="ts">
import { RouterView } from 'vue-router'
import { onMounted } from 'vue'
import { useAuthStore } from '@/stores/auth'

const authStore = useAuthStore()

// 在应用启动时初始化用户认证状态
onMounted(() => {
  authStore.initUser()
})
</script>

<template>
  <RouterView />
</template>

<style>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.47;
  color: var(--text-color);
  background-color: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

#app {
  height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* 页面过渡动画 */
.page-enter-active,
.page-leave-active {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-enter-from,
.page-leave-to {
  opacity: 0;
  transform: translateY(10px);
}

/* 苹果风格滚动条 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-color-secondary);
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-color);
}

/* 焦点样式 */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--button-bg);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* 选择文本样式 */
::selection {
  background-color: rgba(0, 122, 255, 0.2);
  color: var(--text-color);
}

/* 链接样式 */
a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

a:hover {
  color: var(--button-bg);
}

/* 按钮重置 */
button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

button:focus {
  outline: none;
}

/* 输入框重置 */
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* Element Plus 全局样式覆盖 */
.el-loading-mask {
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.el-loading-spinner {
  .circular {
    width: 42px;
    height: 42px;
    border-width: 3px;
    border-color: var(--button-bg) transparent transparent transparent;
  }
}

.el-notification {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  background-color: var(--card-bg);
}

.el-notification__title {
  color: var(--text-color);
  font-weight: 600;
  font-size: 15px;
}

.el-notification__content {
  color: var(--text-color-secondary);
  font-size: 14px;
}

.el-notification-right {
  top: 24px;
  right: 24px;
}

.el-notification-left {
  top: 24px;
  left: 24px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .el-notification-right,
  .el-notification-left {
    top: 12px;
    right: 12px;
    left: 12px;
  }
}

/* 动画优化 */
* {
  transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, backdrop-filter;
  transition-duration: 0.2s;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
</style>
